package com.hifar.enums;

import java.util.*;

/**
 * @Description
 * @Author zhuWeiWei
 * @Date 2024/12/26 16:26
 */
public enum ReportTypeEnum {
    /**
     * 报告模板
     */
    REPORT("报告模板", "report", 1),
    /**
     * 试验委托单模板
     */
//    ENV_ENTRUST("委托单模板", "entrust", 1),
    /**
     * 委托单二维码模板
     */
    ENV_QR_ENTRUST("委托二维码模板", "QREntrustData", 1),
    /**
     * 外协申请单模板
     */
//    ENV_EXT_ASSIST("外协申请单模板", "extAssist", 1),
    /**
     * 原始记录模板
     */
    CLIMATE_ORIGINAL_RECORDS("气候原始记录模板", "climateOriginalRecord", 1),

    /**
     * 原始记录模板
     */
    DYNAMICS_ORIGINAL_RECORDS("力学原始记录模板", "dynamicsOriginalRecord", 1);


    /**
     * 最大数量 -1代表无上限
     */
    private int maxSize;
    /**
     * 模板分类名称
     */
    private String title;
    /**
     * 模板分类编码
     */
    private String value;

    public static List<Map<String, Object>> listData() {
        ReportTypeEnum[] values = ReportTypeEnum.values();
        List<Map<String, Object>> listData = new ArrayList<>(values.length);
        for (ReportTypeEnum value : values) {
            Map<String, Object> itemMap = new HashMap<>(3);
            itemMap.put("title", value.title);
            itemMap.put("value", value.value);
            itemMap.put("maxSize", value.maxSize);
            listData.add(itemMap);
        }
        return listData;
    }

    public static String queryTitle(String value) {
        ReportTypeEnum[] values = ReportTypeEnum.values();
        for (ReportTypeEnum reportTypeEnum : values) {
            String thisValue = reportTypeEnum.value;
            if (Objects.equals(thisValue, value)) {
                return reportTypeEnum.getTitle();
            }
        }
        return null;
    }

    public static int queryMaxSize(String value) {
        ReportTypeEnum[] values = ReportTypeEnum.values();
        for (ReportTypeEnum reportTypeEnum : values) {
            String thisValue = reportTypeEnum.value;
            if (Objects.equals(thisValue, value)) {
                return reportTypeEnum.getMaxSize();
            }
        }
        return -1;
    }

    public static ReportTypeEnum findEnumByCode(String code) {
        ReportTypeEnum[] values = ReportTypeEnum.values();
        for (ReportTypeEnum reportTypeEnum : values) {
            String thisValue = reportTypeEnum.value;
            if (Objects.equals(thisValue, code)) {
                return reportTypeEnum;
            }
        }
        return null;
    }


    public int getMaxSize() {
        return maxSize;
    }

    public String getTitle() {
        return title;
    }

    public String getValue() {
        return value;
    }

    ReportTypeEnum(String title, String value, int maxSize) {
        this.value = value;
        this.title = title;
        this.maxSize = maxSize;
    }
}

